<?php

/**
 * export actions.
 *
 * @package    ppstool
 * @subpackage export
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class exportActions extends sfActions
{
	/**
	 * Executes index action
	 *
	 * @param sfRequest $request A request object
	 */
	public function executeIndex(sfWebRequest $request)
	{
		$xmlstring = $this->getUser()->getAttribute('xmlout');

		if (strlen($xmlstring)>0) {

			$this->xmlout = simplexml_load_string($xmlstring);
			$this->getResponse()->clearHttpHeaders();
			$this->getResponse()->setHttpHeader('Pragma: public', true);
			$this->getResponse()->setHttpHeader('Content-Transfer-Encoding', 'binary', TRUE);
			$filename = "export-".date("Y-m-d_H-i-s").".xml";
			$this->getResponse()->setHttpHeader('Content-Disposition','attachment; filename='.$filename, TRUE);
			$this->getResponse()->setContentType('application/xml');
			$this->getResponse()->sendHttpHeaders();
			$this->getResponse()->setContent($this->xmlout->asXML());

			return sfView::NONE;
		}

	}

}
